package simonby.top.annualring.infrastructure.repository;

import simonby.top.annualring.domain.model.FamilyMember;
import simonby.top.annualring.domain.repository.FamilyMemberRepository;
import org.springframework.stereotype.Repository;
import simonby.top.annualring.infrastructure.dao.FamilyMemberDao;

import java.util.List;
import java.util.Optional;

/**
 * 家族成员仓储的实现
 */
@Repository
public class FamilyMemberRepositoryImpl implements FamilyMemberRepository {
    private final FamilyMemberDao familyMemberDao;

    public FamilyMemberRepositoryImpl(FamilyMemberDao familyMemberDao) {
        this.familyMemberDao = familyMemberDao;
    }

    @Override
    public FamilyMember save(FamilyMember member) {
        return familyMemberDao.save(member);
    }

    @Override
    public Optional<FamilyMember> findById(Long id) {
        return familyMemberDao.findById(id);
    }

    @Override
    public List<FamilyMember> findByFamilyTreeId(Long familyTreeId) {
        return familyMemberDao.findByFamilyTreeId(familyTreeId);
    }

    @Override
    public List<FamilyMember> findAll() {
        return familyMemberDao.findAll();
    }

    @Override
    public void deleteById(Long id) {
        familyMemberDao.deleteById(id);
    }

    @Override
    public List<FamilyMember> findByName(String name) {
        return familyMemberDao.findByName(name);
    }
}